/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nico.db.sql.editor;

import java.util.prefs.Preferences;
import org.openide.util.NbPreferences;

public final class SqlFunctionsPanel extends javax.swing.JPanel {
    public final static String PGIS_PREF_KEY = "resolvePostgisSchema";//NOI18N
    public final static String PGIS_TOPO_PREF_KEY = "resolvePostgisTopoSchema";//NOI18N
    public final static String LIMIT_PARAMS_PREF_KEY = "limitDisplayedParams";//NOI18N

    private final SqlFunctionsOptionsPanelController controller;

    SqlFunctionsPanel(SqlFunctionsOptionsPanelController controller) {
        this.controller = controller;
        initComponents();
        // TODO listen to changes in form fields and call controller.changed()
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        resolvePostGisSchema = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        resolvePostGisTopologySchema = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        limitDisplayedParams = new javax.swing.JCheckBox();
        jLabel4 = new javax.swing.JLabel();

        resolvePostGisSchema.setSelected(true);
        resolvePostGisSchema.setLabel(org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.resolvePostGisSchema.label")); // NOI18N
        resolvePostGisSchema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resolvePostGisSchemaActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 2, 13)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.jLabel1.text")); // NOI18N

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nico/db/sql/editor/completion/resources/postgis.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.jLabel2.text")); // NOI18N

        resolvePostGisTopologySchema.setSelected(true);
        org.openide.awt.Mnemonics.setLocalizedText(resolvePostGisTopologySchema, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.resolvePostGisTopologySchema.text")); // NOI18N
        resolvePostGisTopologySchema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resolvePostGisTopologySchemaActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Lucida Grande", 2, 13)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.jLabel3.text")); // NOI18N

        limitDisplayedParams.setSelected(true);
        org.openide.awt.Mnemonics.setLocalizedText(limitDisplayedParams, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.limitDisplayedParams.text")); // NOI18N
        limitDisplayedParams.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limitDisplayedParamsActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Lucida Grande", 2, 13)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.jLabel4.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel2)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 655, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(resolvePostGisSchema)
                                    .addComponent(resolvePostGisTopologySchema)
                                    .addComponent(limitDisplayedParams)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(29, 29, 29)
                                        .addComponent(jLabel4)))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jLabel3)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(resolvePostGisSchema)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(resolvePostGisTopologySchema)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(limitDisplayedParams))
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addContainerGap(84, Short.MAX_VALUE))
        );

        jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SqlFunctionsPanel.class, "SqlFunctionsPanel.jLabel1.AccessibleContext.accessibleName")); // NOI18N
    }// </editor-fold>//GEN-END:initComponents

    private void resolvePostGisSchemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolvePostGisSchemaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_resolvePostGisSchemaActionPerformed

    private void resolvePostGisTopologySchemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolvePostGisTopologySchemaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_resolvePostGisTopologySchemaActionPerformed

    private void limitDisplayedParamsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limitDisplayedParamsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_limitDisplayedParamsActionPerformed

    void load() {
        // Example:        
        //resolvePostGisSchema.setSelected(Preferences.userNodeForPackage(SqlFunctionsPanel.class).getBoolean(SqlFunctionsPanel.PGIS_PREF_KEY, false));
        // or for org.openide.util with API spec. version >= 7.4:
        resolvePostGisSchema.setSelected(NbPreferences.forModule(SqlFunctionsPanel.class).getBoolean(SqlFunctionsPanel.PGIS_PREF_KEY, false));
        resolvePostGisTopologySchema.setSelected(NbPreferences.forModule(SqlFunctionsPanel.class).getBoolean(SqlFunctionsPanel.PGIS_TOPO_PREF_KEY, false));
        limitDisplayedParams.setSelected(NbPreferences.forModule(SqlFunctionsPanel.class).getBoolean(SqlFunctionsPanel.LIMIT_PARAMS_PREF_KEY, false));
        // or:
        // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
    }

    void store() {
        // Example:
        //Preferences.userNodeForPackage(SqlFunctionsPanel.class).putBoolean(SqlFunctionsPanel.PGIS_PREF_KEY, resolvePostGisSchema.isSelected());
        // or for org.openide.util with API spec. version >= 7.4:
        NbPreferences.forModule(SqlFunctionsPanel.class).putBoolean(SqlFunctionsPanel.PGIS_PREF_KEY, resolvePostGisSchema.isSelected());
        NbPreferences.forModule(SqlFunctionsPanel.class).putBoolean(SqlFunctionsPanel.PGIS_TOPO_PREF_KEY, resolvePostGisTopologySchema.isSelected());
        NbPreferences.forModule(SqlFunctionsPanel.class).putBoolean(SqlFunctionsPanel.LIMIT_PARAMS_PREF_KEY, limitDisplayedParams.isSelected());
        // or:
        // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
    }

    boolean valid() {
        return true;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JCheckBox limitDisplayedParams;
    private javax.swing.JCheckBox resolvePostGisSchema;
    private javax.swing.JCheckBox resolvePostGisTopologySchema;
    // End of variables declaration//GEN-END:variables
}
